import { Controller, Get, Param, Query } from '@nestjs/common';
import { CarbillService } from './carbill.service';
import { RequirePermission } from 'src/common/decorator/require-perm.decorator';
import { User, UserDto } from '../user/user.decorator';
import { ListCarbillDto } from './dto';
import { ResultData } from 'src/common/utils/result';

@Controller('carbill')
export class CarbillController {
  constructor(private readonly carbillService: CarbillService) {}

  @Get('list')
  @RequirePermission('system:enterprise:carbill:list')
  async findAll(@Query() query: ListCarbillDto, @User() user: UserDto) {
    const result = await this.carbillService.findAll(query, user);
    return ResultData.ok(result);
  }

  @Get(':id')
  @RequirePermission('system:enterprise:carbill:detail')
  async findOne(@Param('id') id: string, @User() user: UserDto) {
    const result = await this.carbillService.findOne(id, user);
    return ResultData.ok(result);
  }
}
